package com.larry.tinyweb.core;

import com.larry.tinyweb.core.annotation.AnnotationContainer;
import com.larry.tinyweb.core.log.Logger;
import com.larry.tinyweb.core.log.LoggerFactory;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * Created by larry on 16/12/16.
 *
 * @author larry
 */
public class TinyWeb {
    private static Logger logger = LoggerFactory.getLogger(TinyWeb.class);
    private static final String METHOD = "go";
    public static void start() {
        Object start = AnnotationContainer.getStart();
        try {
            Method go = start.getClass().getMethod(METHOD);
            go.invoke(start);
        } catch (NoSuchMethodException e) {
            logger.error("启动类必须要有一个无参数的名字为go的方法");
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}
